"The specific components of Magma needed to compile processes specifically to Intel Loihi chips remains proprietary to Intel and is not provided through this GitHub site (see below). Similar Magma-layer code for other future commercial neuromorphic platforms likely will also remain proprietary." -- Qoute from Lava README.md
Warning, this NB needs Python-3.8 minimum
To evaluate whether Lava is useful for making bioplausible models, we want to define a variety of overlapping Spiking Neural Network (SNN) architectures, you can think of each one as a weighted directed graph:
Below is a diagram of the Potjan's cortical model. This model can be thought of as the composition of many weighted directed graphs, therefore we will use Lava a supported interface to begin to build a cortical model with the Python Loihi simulator.
from lava.lib.dnf.operations.operations import Weights
from lava.lib.dnf.operations.operations import *
from lava.proc.lif.process import LIF
from lava.lib.dnf.inputs.rate_code_spike_gen.process import RateCodeSpikeGen
from lava.lib.dnf.connect.connect import connect
from lava.lib.dnf.operations.operations import Weights
from lava.magma.core.run_configs import Loihi1SimCfg #Loihi simulator, not Loihi itself.
from lava.magma.core.run_conditions import RunSteps
from lava.proc.monitor.process import Monitor
from lava.proc.monitor.models import PyMonitorModel
from lava.lib.dnf.inputs.gauss_pattern.process import GaussPattern
from lava.lib.dnf.kernels.kernels import MultiPeakKernel
from lava.lib.dnf.utils.plotting import raster_plot
import numpy as np
import elephant
def compute_cv(spikes_population):
'''
Compute coefficient of variation on a whole population of spike trains.
'''
train_of_trains = []
for spike_train in spikes_population.T:
train_of_trains.extend(spike_train)
return elephant.statistics.cv(train_of_trains, axis=0, nan_policy='propagate')
ncolumns=2
# Ex excitatory
ly_2_3_ex = np.ndarray((ncolumns),dtype=object)
ly_4_ex = np.ndarray((ncolumns),dtype=object)
ly_5_ex = np.ndarray((ncolumns),dtype=object)
ly_6_ex = np.ndarray((ncolumns),dtype=object)
# In inhibitory
ly_2_3_in = np.ndarray((ncolumns),dtype=object)
ly_4_in = np.ndarray((ncolumns),dtype=object)
ly_5_in = np.ndarray((ncolumns),dtype=object)
ly_6_in = np.ndarray((ncolumns),dtype=object)
ncells = 85
for i in range(0,ncolumns):
ly_2_3_ex[i] = LIF(shape=(ncells,))
ly_4_ex[i] = LIF(shape=(ncells,))
ly_5_ex[i] = LIF(shape=(ncells,))
ly_6_ex[i] = LIF(shape=(ncells,))
ly_2_3_in[i] = LIF(shape=(ncells,))
ly_4_in[i] = LIF(shape=(ncells,))
ly_5_in[i] = LIF(shape=(ncells,))
ly_6_in[i] = LIF(shape=(ncells,))